package cn.wwk.canal.controller;

import cn.wwk.canal.domain.User;
import cn.wwk.canal.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wwk
 */
@RestController
@Slf4j
@RequestMapping("/user")
public class UserController {


    @Autowired
    private UserService userService;

    /**
     * 获得全部用户
     * */
    @GetMapping("/list")
    public List<User> getAll(){
        log.info("获得全部用户");
        return userService.list();
    }

    /**
     * 插入数据
     * */
    @PostMapping("/add")
    public boolean addUser(@RequestBody User user){
//        userService.removeById(1);
        return userService.save(user);
    }
}
